package com.wnxy.pawnbackgroundsystem.controller;


import com.wnxy.pawnbackgroundsystem.dto.BrandPageDto;
import com.wnxy.pawnbackgroundsystem.dto.userDto.GetGoodsBrandDto;
import com.wnxy.pawnbackgroundsystem.param.BrandJuniorParam;
import com.wnxy.pawnbackgroundsystem.param.GetBrandParam;
import com.wnxy.pawnbackgroundsystem.response.Result;
import com.wnxy.pawnbackgroundsystem.service.impl.BrandServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商品品牌表 前端控制器
 * </p>
 *
 * @author Lucas
 * @since 2021-10-14
 */
@RestController
@RequestMapping("/pawnbackgroundsystem/brand")
@Slf4j
public class BrandController {

    @Autowired
    private BrandServiceImpl brandServiceImpl;

    //分页带条件查询品牌
    @PostMapping("/getBrand")
    @CrossOrigin("*")
    public Result getBrand(@RequestBody GetBrandParam getBrandParam){
        log.info("分页带条件查询品牌接口 参数={}",getBrandParam);
        BrandPageDto brand = brandServiceImpl.getBrand(getBrandParam);
        return new Result(true,"2002","查询集合成功",brand);
    }
    //删除品牌
    @DeleteMapping("/delBrand")
    @CrossOrigin("*")
    public Result delBrand(@RequestParam(value = "intList") List<Integer> intList){
        log.info("删除品牌接口 参数={}",intList);
        brandServiceImpl.delBrand(intList);
        return new Result(true,"2002","删除成功",null);
    }
    //新增修改品牌
    @PostMapping("/brandJunior")
    @CrossOrigin("*")
    public Result brandJunior(@RequestBody BrandJuniorParam brandJuniorParam){
        log.info("新增修改品牌接口 参数={}",brandJuniorParam);
        brandServiceImpl.brandJunior(brandJuniorParam);
        return new Result(true,"2002","操作成功",null);
    }
    //商品查询所有品牌
    @GetMapping("/getGoodsBrand")
    @CrossOrigin("*")
    public Result getGoodsBrand(){
        List<GetGoodsBrandDto> goodsBrand = brandServiceImpl.getGoodsBrand();
        return new Result(true,"2002","查询集合成功成功",goodsBrand);
    }
}

